package com.yzy.fly.mapper;

import com.yzy.fly.entity.core.FlyField;
import com.yzy.fly.kernel.mapper.FlyBasicMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Collection;
import java.util.List;


@Mapper
public interface FlyFieldMapper extends FlyBasicMapper<FlyField> {

    @Select("select * from fly_field a where 1=1")
    List<FlyField> selectAll();

    @Select("select * from fly_field a where 1=1 and a.classId = #{classId} order by a.seq asc")
    List<FlyField> selectAllByClassId(@Param("classId") int classId);

    @Select("select * from fly_field a where 1=1 and a.id = (select b.fieldId from fly_field_annotation b where b.id = #{annotationId})")
    FlyField selectOneByAnnotationId(@Param("annotationId") int annotationId);

    @Select("select * from fly_field a where 1=1 and a.name = #{name}")
    FlyField selectOneByName(@Param("name") String name);

    /**
     * 批量插入（mysql）
     * @param entityList
     * @return
     */
    Integer insertBatchSomeColumn(Collection<FlyField> entityList);
}